const ValidateData = require("./lib/ValidateData");
const schema = require("./schema/schema.js");

let data = {
  name: "mike",
  age: 20,
  sex: 1,
  graduated: true,
  hobby: ["football", "running", "piano", "reading"],
  email: "123@qq.com",
  ip: "192.168.0.1",
}
let res = ValidateData(data, schema)
console.log("ok:",res);
// -----------------------------------------------------------------------
data = {
  name: "mark",
  age: 12,
  sex: -1,
}
res = ValidateData(data, schema)
console.log("sex enum:",res);
// -----------------------------------------------------------------------
data = {
  age: 12,
}
res = ValidateData(data, schema)
console.log("lack of name: ",res);
// -----------------------------------------------------------------------
data = {
  name: "extra",
  age: 12,
  sex: 1,
  extra: "extra",
}
res = ValidateData(data, schema)
console.log("extra: ",res);
// -----------------------------------------------------------------------
data = {
  name: "names",
  age: 12,
  sex: 1,
  graduated: "123",
}
res = ValidateData(data, schema)
console.log("boolean type: ",res);
// -----------------------------------------------------------------------
data = {
  name: "names",
  age: 140,
}
res = ValidateData(data, schema)
console.log("exclusive maximum: ",res);
// -----------------------------------------------------------------------
data = {
  name: "names",
  age: 12,
  hobby: [1, "running", "piano", "reading"],
}
res = ValidateData(data, schema)
console.log("array item type: ",res);
// -----------------------------------------------------------------------
data = {
  name: "names",
  age: 12,
  hobby: ["running", "piano"],
}
res = ValidateData(data, schema)
console.log("array item minitems: ",res);
// -----------------------------------------------------------------------
data = {
  name: "names",
  age: 12,
  hobby: ["1", "2", "3", "4", "5", "6", "7"],
}
res = ValidateData(data, schema)
console.log("array item exclusivemaxitems: ",res);
// -----------------------------------------------------------------------
data = {
  name: "names",
  age: 12,
  hobby: ["1", "2", "1"],
}
res = ValidateData(data, schema)
console.log("array item unique: ",res);
// -----------------------------------------------------------------------
data = {
  name: "names",
  age: 12,
  email: "http://123@qq.com"
}
res = ValidateData(data, schema)
console.log("email format: ",res);
// -----------------------------------------------------------------------
data = {
  name: "names",
  age: 12,
  ip: "192.168.0.256",
}
res = ValidateData(data, schema)
console.log("ipv4 format: ",res);